package com.example.tourstor.myself;

import android.content.Intent;
import android.graphics.Color;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.Toolbar;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;

import com.example.tourstor.MainActivity;
import com.example.tourstor.R;

public class RegisterActivity extends AppCompatActivity {

    Toolbar register_toolbar;
    Button btn_register;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_register);

        setToolBar();
        initListener();
    }

    private void setToolBar() {
        register_toolbar = (Toolbar) findViewById(R.id.register_toolbar);
        register_toolbar.setTitle("注册");
        register_toolbar.setTitleTextColor(Color.WHITE);

        this.setSupportActionBar(register_toolbar);
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);//左侧添加一个默认的返回图标
        getSupportActionBar().setHomeButtonEnabled(true);//设置返回键可用
        this.getSupportActionBar().setDisplayShowTitleEnabled(true);
    }

    //Toolbar的事件---返回
    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        if(item.getItemId() == android.R.id.home){
            finish();
        }
        return super.onOptionsItemSelected(item);
    }

    public void initListener(){
        btn_register = (Button) findViewById(R.id.btn_login);
        btn_register.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(RegisterActivity.this, MainActivity.class);
                intent.putExtra("num", 4);
                startActivity(intent);
            }
        });
    }

}
